﻿using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;

namespace RapidDownloader.Modules.Views.Shaders
{
    public class HueEffect : ShaderEffect
    {
        public static DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(HueEffect), 0);
        public static DependencyProperty HueProperty = DependencyProperty.Register("Hue", typeof(double), typeof(HueEffect), new System.Windows.UIPropertyMetadata(new double(), PixelShaderConstantCallback(0)));
        public static DependencyProperty SaturationProperty = DependencyProperty.Register("Saturation", typeof(double), typeof(HueEffect), new System.Windows.UIPropertyMetadata(new double(), PixelShaderConstantCallback(1)));

        public HueEffect()
        {
            PixelShader = new PixelShader { UriSource = new Uri(@"pack://application:,,,/RapidDownloader.Modules.Views;component/Shaders/Hue.ps") };

            this.UpdateShaderValue(InputProperty);
            this.UpdateShaderValue(HueProperty);
            this.UpdateShaderValue(SaturationProperty);
        }

        public virtual System.Windows.Media.Brush Input
        {
            get
            {
                return ((System.Windows.Media.Brush)(GetValue(InputProperty)));
            }
            set
            {
                SetValue(InputProperty, value);
            }
        }

        public virtual double Hue
        {
            get
            {
                return ((double)(GetValue(HueProperty)));
            }
            set
            {
                SetValue(HueProperty, value);
            }
        }

        public virtual double Saturation
        {
            get
            {
                return ((double)(GetValue(SaturationProperty)));
            }
            set
            {
                SetValue(SaturationProperty, value);
            }
        }
    }
}
